package com.spring.services;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.spring.dao.StudentsDAO;
import com.spring.domain.Students;

@Service
public class ServicesImpl implements Services {
	
	@Autowired
	private StudentsDAO studentsDAO;

	@Override
	@Transactional
	public Students getStudent(int id) {
		return studentsDAO.getStudent(id);
	}

	@Override
	@Transactional
	public List<Students> getListStudents() {
		return studentsDAO.getListStudents();
	}

	@Override
	@Transactional
	public boolean saveStudent(Students s) {
		studentsDAO.saveStudent(s);
		return true;
	}

	@Override
	@Transactional
	public boolean deleteStudent(Students s) {
		studentsDAO.deleteStudent(s);
		return true;
	}

	@Override
	@Transactional
	public boolean updateStudent(Students s) {
		try {
			studentsDAO.updateStudent(s);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			return false;
		}
		return true;
	}

}
